package com.spring.sunflower.common;

import com.spring.sunflower.base.BaseObserver;
import com.spring.sunflower.base.BasePresenter;
import com.spring.sunflower.bean.CommonBean;
import com.spring.sunflower.bean.LabelBean;

import io.reactivex.rxjava3.core.Observable;

/**
 * Created by Kevin on 2021/6/28<br/>
 * <p>
 * Describe:<br/>
 */
public class OnlineStatusPresenter extends BasePresenter<CommonContract.OnlineStatusView> {
    public OnlineStatusPresenter(CommonContract.OnlineStatusView baseView) {
        super(baseView);
    }

    public void getOnlineStatus() {
        Observable<LabelBean> observable = requestDataSource.requestLabel("onlineMood");
        addDisposable(observable, new BaseObserver<LabelBean>(baseView) {

            @Override
            public void onSuccess(LabelBean bean) {
                baseView.showOnlineStatus(bean.getDatas());
            }

            @Override
            public void onError(int status, String msg) {

            }
        });
    }

    public void setOnlineStatus(String id) {
        Observable<CommonBean> observable = requestDataSource.setOnlineStatus(id);
        addDisposable(observable, new BaseObserver<CommonBean>(baseView) {

            @Override
            public void onSuccess(CommonBean bean) {
                baseView.setOnlineStatusSuccess();
            }

            @Override
            public void onError(int status, String msg) {

            }
        });
    }
}
